<?php
include("include/haut.php");
if(!isset($_GET['id'])){
	header('Redirect: index.php');
	exit();
}
if(isset($_POST['comment'])){
	ajouterCommentNews($_GET['id'], $_POST['comment'],$_SESSION['id']);
}
$news = getNewsID($_GET['id']);
?>

<div id="corps">
	<h1>News</h1>
	<div id="centre">
		<p>
		<?php
		echo "<h2>".$news['titre']."</h2>";
		echo $news['news'];
		echo "par ".getPseudoID($news['auteur'])." le: ".date("d/m/Y à H:i",$news['date']);
		?>
	</P>
		<h2>Commentaires</h2><p>

		<?php
		$commentaires = getCommentaireNews($_GET['id']);

						while($a= mysql_fetch_array($commentaires)) {
		?>
							<div id="commentaire"><?php
							echo "<em> Le : ".date("d/m/y à H:i",$a['date'])."";?>
							<em>par <a href="profil.php?id=<?php echo $a['id_membre']; ?>"><?php echo getPseudoID($a['id_membre']); ?></a></em></em><br/><br/>
							<?php
							echo $a['message'];?>
							</div>
							<?php
						}
if(isConnected()){
	?>
		<h3 id="newsc">Nouveau Commentaire</h3>
		<p>
			<form action="" method="POST">
				<div id="tiny_mce">
				<textarea id="comment" name="comment" rows="20" cols="70">

				</textarea><br />
				<input type="submit" value="envoyer">
			</div>
			</form>
		</p>
<?php
}
else{
	echo "Vous n'êtes pas connecté"
}
?>

	</p>
	</div>
</div>

<?php
include("include/bas.php");
?>
